package com.lxh.lxhcrm.model.pojos;

import javax.persistence.*;
import java.util.List;
import java.util.Objects;

/**
 * 功能表
 */
@Entity
public class Function {
    private int functionId;
    private String functionName;
    private String accessPath;
    private String funIcon;
    private Integer isShow;
    private String functionLevel;
    private Integer funParentId;
    private Integer functionSort;
    /*权限对职位 多对多*/
    private List<Position> post;
    @ManyToMany(mappedBy = "functions")
    public List<Position> getPost() {
        return post;
    }

    public void setPost(List<Position> post) {
        this.post = post;
    }


    @Override
    public String toString() {
        return "Function{" +
                "functionId=" + functionId +
                ", functionName='" + functionName + '\'' +
                ", accessPath='" + accessPath + '\'' +
                ", funIcon='" + funIcon + '\'' +
                ", isShow=" + isShow +
                ", functionLevel='" + functionLevel + '\'' +
                ", funParentId=" + funParentId +
                ", functionSort=" + functionSort +
                ", post=" + post +
                ", functionType=" + functionType +
                '}';
    }

    private FunctionType functionType;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="function_type_id" )
    public FunctionType getFunctionType() {
        return functionType;
    }

    public void setFunctionType(FunctionType functionType) {
        this.functionType = functionType;
    }

    @Id
    @Column(name = "function_id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public int getFunctionId() {
        return functionId;
    }

    public void setFunctionId(int functionId) {
        this.functionId = functionId;
    }

    @Basic
    @Column(name = "function_name", nullable = true, length = 40)
    public String getFunctionName() {
        return functionName;
    }

    public void setFunctionName(String functionName) {
        this.functionName = functionName;
    }


    @Basic
    @Column(name = "access_path", nullable = true, length = 40)
    public String getAccessPath() {
        return accessPath;
    }

    public void setAccessPath(String accessPath) {
        this.accessPath = accessPath;
    }

    @Basic
    @Column(name = "fun_icon", nullable = true, length = 40)
    public String getFunIcon() {
        return funIcon;
    }

    public void setFunIcon(String funIcon) {
        this.funIcon = funIcon;
    }

    @Basic
    @Column(name = "is_show", nullable = true)
    public Integer getIsShow() {
        return isShow;
    }

    public void setIsShow(Integer isShow) {
        this.isShow = isShow;
    }

    @Basic
    @Column(name = "function_level", nullable = true, length = 40)
    public String getFunctionLevel() {
        return functionLevel;
    }

    public void setFunctionLevel(String functionLevel) {
        this.functionLevel = functionLevel;
    }

    @Basic
    @Column(name = "fun_parent_id", nullable = true)
    public Integer getFunParentId() {
        return funParentId;
    }

    public void setFunParentId(Integer funParentId) {
        this.funParentId = funParentId;
    }

    @Basic
    @Column(name = "function_sort", nullable = true)
    public Integer getFunctionSort() {
        return functionSort;
    }

    public void setFunctionSort(Integer functionSort) {
        this.functionSort = functionSort;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Function function = (Function) o;
        return functionId == function.functionId &&
                Objects.equals(functionName, function.functionName) &&

                Objects.equals(accessPath, function.accessPath) &&
                Objects.equals(funIcon, function.funIcon) &&
                Objects.equals(isShow, function.isShow) &&
                Objects.equals(functionLevel, function.functionLevel) &&
                Objects.equals(funParentId, function.funParentId) &&
                Objects.equals(functionSort, function.functionSort);
    }

    @Override
    public int hashCode() {
        return Objects.hash(functionId, functionName, accessPath, funIcon, isShow, functionLevel, funParentId, functionSort);
    }
}
